<template>
    <div>
        <login-top middleTop="登录bilibili">
            <div slot="right" @click="$router.push('/register')">跳转</div>
        </login-top>
        <login-text  style="margin: 4.167vw" @inputChange="content => user.username = content"  label="账号" placeholder="请输入账号"></login-text>
        <login-text  style="margin: 4.167vw" @inputChange="content => user.password = content"  label="密码" placeholder="请输入密码" type="password"></login-text>
        <login-btn btntext="登录" @registerSubmit="registerSubmit"></login-btn>
    </div>
</template>

<script>
    import LoginTop from "../components/common/LoginTop";
    import LoginText from "../components/common/LoginText";
    import LoginBtn from "../components/common/LoginBtn";
    export default {
        components: {
            LoginTop,
            LoginText,
            LoginBtn
        },
        data() {
            return{
                user: {
                    username: '',
                    password: ''
                }
            }
        },
        methods:{
            async registerSubmit() {
                const res = await this.$http.post('/login',this.user)
                localStorage.setItem('token',res.data.token)
                localStorage.setItem('id',res.data.id)
                setTimeout(() =>{
                    this.$router.push('/userinfo')
                },1000)
            }
        }
    }
</script>

<style>

</style>